package com.pingba.serviceImpl.friend;

import com.pingba.dao.BaseDao;
import com.pingba.dao.friend.FriendRelationDao;
import com.pingba.entity.User;
import com.pingba.entity.friend.FriendRelation;
import com.pingba.service.friend.FriendRelationService;
import com.pingba.serviceImpl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2015/11/10 0010.
 */
@Service("FriendRelationService")
public class FriendRelationServiceImpl extends BaseServiceImpl<FriendRelation, Long> implements FriendRelationService {

    @Autowired
    private FriendRelationDao friendRelationDao;

    @Override
    public BaseDao<FriendRelation, Long> getDao() {
        return friendRelationDao;
    }

    @Override
    public List<User> getMyFriends(long userId) {
        return friendRelationDao.getMyFriends(userId);
    }

    @Override
    public boolean isFriend(long fromId, long toId) {
        List<FriendRelation> friendRelationList = friendRelationDao.isFriend(fromId,toId);
        if (friendRelationList.size() > 0) {
            return true;
        }
        return false;
    }

    @Override
    public int beFriends(long fromId, long toId,long time) {
        return friendRelationDao.beFriends(fromId,toId, time);
    }
}
